package com.qk.common.api;

import com.qk.common.property.SmsProperties;
import com.qk.common.util.HttpUtils;
import org.apache.http.HttpResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author:gzc
 * @Date: 2025/10/09 18:42
 * @Description:
 */
@Component
public class SmsApi {

    @Autowired
    private SmsProperties smsProperties;
    public void sendSms(Map<String, String> querys) throws Exception {
        Map<String, String> headers = new HashMap<>();
        //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
        headers.put("Authorization", "APPCODE " + smsProperties.getAppcode());
        Map<String, String> bodys = new HashMap<>();


        try {
            HttpResponse response = HttpUtils.doPost(smsProperties.getHost(), smsProperties.getPath(), smsProperties.getMethod(), headers, querys, bodys);
//            System.out.println(response.toString());
            //获取response的body
//            System.out.println(EntityUtils.toString(response.getEntity()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
